package cn.yangliu;

import cn.yangliu.ui.MainSettingUI;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import org.jetbrains.annotations.NotNull;

/**
 * @author mechrevo
 */
public class MainAction extends AnAction {
    private MainSettingUI mainSettingUI;

    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {

        if (mainSettingUI == null) {
            mainSettingUI = new MainSettingUI(event.getData(PlatformDataKeys.PROJECT));
        }

        if (mainSettingUI.isShowing()) {
            if (!mainSettingUI.isAlwaysOnTop()) {
                mainSettingUI.setAlwaysOnTop(true);
            }
            return;
        }

        mainSettingUI.setVisible(true);
        mainSettingUI.setAlwaysOnTop(true);
    }
}

